﻿<!--#include file="admin/Includes/constants.asp"-->
<!--#include file="admin/Includes/validate.asp"-->
<!--#include file="admin/Includes/Send_Mail.asp"-->
<!--#include file="admin/Includes/validation.asp"-->
<%
Dim origmail_source, origmail_subject, origmail_body, Icon
Dim UserEmail, FromName, FromEmail, ToName, ToEmail, MsgHeading, MsgText, ImageID, ImageName, SoundName, Layout, Style, isNotifySender, ArticleBackLink, eCardViewLink, DateExpire, MsgID, Orientation, AccessCode
Dim reqtype
Dim hideform, strMes, Action
Dim ccname1, ccname2, ccname1_em, ccname2_em, scc


ccname1 = request("ccname1")
ccname2 = request("ccname2")
ccname1_em = request("ccname1_em")
ccname2_em = request("ccname2_em")


reqtype=request("r")
UserEmail=iv_RetEmail

If request("MsgID") <> "" Then
	MsgID=request("MsgID")
Else
	MsgID=0
End If

'passed from detail page
Orientation=request("o") 
ImageID=request("iid")
ImageName=request("in")

If request.Form("ArticleBackLink") <> "" Then
	ArticleBackLink=request.Form("ArticleBackLink")
Else
	ArticleBackLink="http://" & request.ServerVariables("HTTP_HOST") & "/detail.asp?aid=" & request("aid")
End If

FromName=request("rqFromName")
FromEmail=request("rqFrom_em")
ToName=request("rqToName")
ToEmail=request("rqTo_em")
If request("MsgHeading") <> "" Then
	MsgHeading=Trim(request("MsgHeading"))
End If
If request("rqMsgText") <> "" Then
	MsgText=Trim(request("rqMsgText"))
End If

isNotifySender=request("isNotifySender")
Layout=request("Layout")
SoundName=request("SoundName")

If request("Style") <> "" Then
	Style=request("Style")
Else
	Style=1
End If

If request("DateExpire") <> "" Then
	DateExpire=DateAdd("m",request("DateExpire"),now())
Else
	DateExpire=DateAdd("m",1,now())
End If

If request("act") = "GỞI THIỆP" Then
	Action = "ins"
ElseIf request("act") = "SỬA THIỆP" Then
	Action = "upd"
End If


If Action = "ins" or Action = "upd" Then

dim psemail 
psemail = getpsemail()

	'Sendmail
	if isEmail (FromEmail) then
		strSQL = "{CALL a_eCard_Upd ('"&Action&"','"&UserEmail&"',N'"&FromName&"','"&FromEmail&"',N'"&ToName&"','"&ToEmail&"',N'"&MsgHeading&"',N'"&MsgText&"','"&ImageName&"','"&SoundName&"',"&Layout&","&Style&","&isNotifySender&",'"&ArticleBackLink&"','"&DateExpire&"',"&MsgID&","&ImageID&")}"		
		exec(strsql)		
		If Not RS Is Nothing Then
			If Not RS.EOF Then
				MsgID = RS(0)	
				AccessCode=RS(1)			
			End If
		End If	
		If MsgID > 1 and AccessCode > 0 Then
			'main address
			sendecard ToName, ToEmail
			'cc 1
			if ccname1 <> "" and ccname1_em <> "" then 	sendecard ccname1, ccname1_em			
			'cc 2
			if ccname2 <> "" and ccname2_em <> "" then 	sendecard ccname2, ccname2_em
		
			sub sendecard (ToName1, ToEmail1)
				origmail_source  = Domain_Name	
				origmail_subject = ToName1 & ": bạn có 1 thiệp số ở ThoiTrang.com"
				eCardViewLink = "http://" & request.ServerVariables("HTTP_HOST") & "/ecard_det.asp?msgid=" & MsgID & "&ac=" & AccessCode
				origmail_body  = ToName1 &" mến,<br><br>" &FromName&" vừa gửi cho bạn 1 thiệp số thời trang. Bạn có thể xem thiệp của bạn bằng cách bấm vào đường link sau<br><br><a href='"& eCardViewLink &"'>" & eCardViewLink & "</a><br><br>Thân ái,<br><br><a href='http://www.thoitrang.com'>ThoiTrang.com</a><br>" & psemail
				
				call sentMail(strSMTP, FromEmail, FromName, ToEmail1, origmail_subject, origmail_body)	
			end sub	
			strMes = "Cảm ơn <b>" & FromName & "</b>! Thiệp của bạn đã được gởi đến cho <b>" & ToName	& "</b>"			
			hideform = true	
		End If	
		CloseCon
	else	
		origmail_subject = Replace(request.form("subject"),"'","''")	
		Icon = "<img src='hinh-thoi-trang/ico_alert.gif' alt='' width='20' height='20' border='0'>"
		strMes = "Xin vui lòng nhập lại email."	
	end if	

	
End If	




%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<Meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Thoitrang.com-gui thiep so</title>
	<Meta http-equiv=" content-language" content ="vi">
	<Meta name="Robots" content="noindex,nofollow">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="STYLESHEET" type="text/css" href="system/styles.css">
	<script src="admin/javascripts/vietUni.js" type="text/javascript"></script>
	<script language="javascript">setTypingMode(2);</script>
	<script language="javascript" src="admin/javascripts/validateVN.js"></script>
	<script> 
	function preview() 
	{ 
		document.frm.target="previewWindow";
		document.frm.action="ecard_det_preview.asp";
		window.open("","previewWindow","width=600,height=600,toolbar=0,resizable=1,scrollbars=1,status=1"); 
		var a = window.setTimeout("document.frm.submit();",1000); 
	} 	
	function sendcard() 
	{ 
		document.frm.target="";
		document.frm.action="ecard.asp?ckid=<%=ckid%>";
	} 	
	function validate(frm){
		if (isValid(frm) == false) return false;
		if ( (frm.ccname1.value != "" && frm.ccname1_em.value  == "" ) || (frm.ccname1.value == "" && frm.ccname1_em.value  != "" ) ) { alert("Ban phải nhập đầy đủ tên và email người nhận");return false};
		if ( (frm.ccname2.value != "" && frm.ccname2_em.value  == "" ) || (frm.ccname2.value == "" && frm.ccname2_em.value  != "" ) ) { alert("Ban phải nhập đầy đủ tên và email người nhận");return false};		
		return true;
	}
</script>	
</head>
<body>
<div id="container">
<div id="bt2"><img src="hinh-thoi-trang/bg_top.gif" width="1049" height="20"></div>
<div id="tp">
<table border="0" cellpadding="0" cellspacing="0" width="990" align="center">	
	<!--top-->
	<!--#include file="system/top.asp" -->
	<!--/top-->
	<tr bgcolor="#6b5a60">
		<td width="160" style="height:1px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
		<td width="522" valign="top" rowspan="2">		
		<!--body content-->		
			<!--cover-->		
		<table border="0" cellpadding="0" cellspacing="1" width="100%" bgcolor="#B6A8AD">			
			<tr><td colspan="3" style="padding-left:12px;"><img src="hinh-thoi-trang/gui-thiep-so-hp.gif" width="400" height="40"></td></tr>
			<tr>
				<!--col left-->		
				<td valign="top" height=680><div id="test"></div>
					<table cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF" width=100%%>
						<tr>
							<td style="padding:9px 9px 9px 9px;" valign="top">
								<table cellpadding="3" cellspacing="0" border="0" style="border:solid #CEC3C7 1px;" align="center">								
								<% If strMes <> "" Then%>
									<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="10" border="0"></td></tr>	
									<tr><td colspan="3" class="text"><P class="paging"><%=strMes%></P></td></tr>
								<%	End If%>
								<%If hideform = False Then%>								
								<form name ="frm" action="ecard.asp?ckid=<%=ckid%>" method="post" onSubmit="return validate(this)">	
								<input type="hidden" name="iid" value="<%= ImageID %>">
								<input type="hidden" name="in" value="<%= ImageName %>">		
								<input type="hidden" name="ArticleBackLink" value="<%= ArticleBackLink %>">	
								<input type="hidden" name="MsgID" value="<%= MsgID %>">		
								<input type="hidden" name="prev" value="1">				
								<tr>
								  	<td class="paging" colspan="2">&nbsp;</td>
									<td align="right" style="padding:0px;">
										<table cellpadding="0" cellspacing="0" border="0" bgcolor="CEC3C7">
										<tr><td class="paging" align="right" style="font-size:9px;padding:0px 8px 0px 8px;"><input type="radio" name="optInput" value="0" onFocus="setTypingMode(0)"/>Off&nbsp;&nbsp;<input type="radio" name="optInput" value="1" onFocus="setTypingMode(1)"/>Telex&nbsp;&nbsp;<input type="radio" name="optInput" value="2" onFocus="setTypingMode(2)" checked="checked"/>VNI</td></tr>
										</table>
									</td>
								</tr>
								<tr>		
									<td class="paging">&nbsp;</td>							
									<td class="paging"><strong style="color:#8D0045">Tên</b></td>
									<td class="paging"><strong>Email</strong></td>
								</tr>	
								<tr><td colspan="3" bgcolor="#CEC3C7" style="padding:0px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
								<tr bgcolor="#E5DFE1">									
									<td class="paging"><strong>Người gửi</strong>:</td>
									<td><input type="text" name="rqFromName" id="Tên người gửi" onKeyUp="initTyper(this)" size="51" style="Width:140px;" class="txtInput" value="<%=iv_Fullname%>"></td>
									<td><input type="text" name="rqFrom_em" id="Email bạn" size="51" style="Width:233px; background-color:#CDC4C7" class="txtInput" value="<%=iv_RetEmail%>"></td>
								</tr>
								<tr><td colspan="3" bgcolor="#CEC3C7" style="padding:0px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
								<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
								<tr>									
									<td class="paging"><strong>Nguời nhận</strong> 1:</td>
									<td><input type="text" name="rqToName" onKeyUp="initTyper(this)" id="Tên nguời nhận" size="51" style="Width:140px;" class="txtInput"></td>
									<td><input type="text" name="rqTo_em" id="Email nguời nhận" size="51" style="Width:233px;background-color:#CDC4C7" class="txtInput"></td>
								</tr>																	
								<tr>									
									<td class="paging"  valign="top">Nguời nhận 2:</td>
									<td valign="top"><input type="text" name="ccname1" onKeyUp="initTyper(this)" id="Tên nguời nhận khác 1" size="51" style="Width:140px;" class="txtInput"></td>
									<td><input type="text" name="ccname1_em" id="Email nguời nhận khác 1" size="51" style="Width:233px;background-color:#CDC4C7" class="txtInput"></td>
								</tr>									
								<tr>									
									<td class="paging"  valign="top">Nguời nhận 3:</td>
									<td valign="top"><input type="text" name="ccname2" onKeyUp="initTyper(this)" id="Tên nguời nhận khác 2" size="51" style="Width:140px;" class="txtInput"></td>
									<td><input type="text" name="ccname2_em" id="Email nguời nhận khác 2" size="51" style="Width:233px;background-color:#CDC4C7" class="txtInput"></td>
								</tr>	
								<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
								<tr><td colspan="3" bgcolor="#CEC3C7" style="padding:0px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
																								
								<tr bgcolor="#E5DFE1">									
									<td class="paging"><strong>Lời Tựa</strong>:</td>
									<td colspan="2"><input type="text" name="MsgHeading" onKeyUp="initTyper(this)" id="Lời Tựa" size="51" style="Width:387px;background-color:#F7F6BD" class="txtInput"></td>
								</tr>	
								<tr bgcolor="#E5DFE1">									
									<td valign="top" class="paging"><strong>Nội dung</strong>:&nbsp;&nbsp;</td>
									<td colspan="2"><textarea cols="50" rows="9" name="rqMsgText" onKeyUp="initTyper(this)" id="Nội dung" style="Width:387px;background-color:#F7F6BD" class="txtInput"></textarea></td>
								</tr>
								<tr><td colspan="3" bgcolor="#CEC3C7" style="padding:0px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
								<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
								
								<tr>									
									<td class="paging" nowrap>Báo tin nhận:</td>
									<td colspan="2"><select name="isNotifySender" id="Báo tin sau khi người nhận đọc thiệp" style="Width:174px;" class="txtInput">	
										<option value="0">Không báo</option>		
										<option value="1">Email báo tin cho tôi</option>		
									</select>
									</td>
								</tr>	
								<!--
								<tr>									
									<td class="paging" nowrap>Kèm theo nhạc:</td>
									<td class="paging"><select name="SoundName" id="Kèm theo nhạc" style="Width:200px;" class="txtInput">	
										<option value="">Không kèm nhạc</option>		
										<option value="happy-birthday">Happy birthday</option>		
									</select> <a href="#" class="NavBottom" style="color:#000000;">Nghe</a>	
									</td>
								</tr>									
								<tr>									
									<td class="paging" nowrap>Mẫu thiết kế:</td>
									<td class="paging"><select name="Style" id="Mẫu thiết kế" style="Width:200px;" class="txtInput">	
										<option value="1">Chuyên nghiệp</option>		
										<option value="2">Lã lướt</option>		
									</select> <a href="#" class="NavBottom" style="color:#000000;">Xem</a>
									</td>
								</tr>	
								
								<tr>									
									<td class="paging" nowrap>Lưu trữ thiệp:</td>
									<td><select name="DateExpire" id="Thời gian lưu thiệp" style="Width:200px;" class="txtInput">	
										<option value="1">1 tháng</option>		
										<option value="2">2 tháng</option>
										<option value="3">3 tháng</option>		
									</select>		
									</td>
								</tr>	
								-->
								<tr>									
									<td class="paging" nowrap valign="top">Kiểu trình bày:</td>
									<td colspan="2">
										<table cellpadding="0" cellspacing="0" border="0">
										<tr>
											<% If Orientation="h" Then %>
											<td><img src="hinh-thoi-trang/ecard-layout-2.gif" width="83" height="62" hspace="5"></td>	
											<td><img src="hinh-thoi-trang/ecard-layout-1.gif" width="83" height="62"></td>											
											<% Else %>										
											<td><img src="hinh-thoi-trang/ecard-layout-4.gif" width="83" height="62"></td>
											<td><img src="hinh-thoi-trang/ecard-layout-3.gif" width="83" height="62"  hspace="5"></td>
											<% End If %>
										</tr>
										<tr>
											<% If Orientation="h" Then %>
											<td class="paging" align="center"><input name="Layout" type="radio" value="2" checked="checked"></td>
											<td class="paging" align="center"><input name="Layout" type="radio" value="1"></td>											
											<% Else %>			
											<td class="paging" align="center"><input name="Layout" type="radio" value="4" checked="checked"></td>
											<td class="paging" align="center"><input name="Layout" type="radio" value="3"></td>
											<% End If %>
										</tr>	
										</table>
									</td>
								</tr>
								<tr bgcolor="#CEC3C7"><td align="right" colspan="3" style="padding-right:5px;" height="22"><input type="button" value="XEM TRƯỚC" class="btnGo" onClick='preview();'><% If reqtype="e" Then %><input type="submit" name="act" value="SỬA THIỆP" class="btnGo"><% Else %><input type="submit" name="act" value="GỞI THIỆP" class="btnGo" onClick="sendcard()"><% End If %></td></tr>			
								</form>								
								<%else%>
								<tr><td align="right" colspan="3"><br><br>
									<a href="<%= ArticleBackLink %>&ckid=<%=ckid%>"><img src="hinh-thoi-trang/btn_continue.gif" border="0" width="82" height="17"></a>
								</td></tr>
								<%end if%>									
							</table>										
							</td>
						</tr>
						<tr><td><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="15" border="0"></td></tr>
						<tr bgcolor="B6A8AD"><td><h5 style="padding: 10px 15px 0px 12px;display:block;"><strong>Chính sách NO-SPAM </strong><br>
						ThoiTrang.com thiết lập một chính sách NO-SPAM (hòan tòan không có thư rác) 
						đối với email của các bạn và tuyệt đối không cung cấp cho một bên thứ ba. Email của các bạn chỉ dùng để liên lạc các vấn 
						đề hoặc thông tin thời trang mà bạn yêu cầu. Bạn có thể xem <a href="privacypolicy.asp?ckid=<%=ckid%>" class="link" style="text-decoration:underline;">Chính sách bảo mật</a> của chúng tôi để
						biết thêm chi tiết.
						</h5></td></tr>
					</table>						 
				</td>
				<!--/col left-->							
			</tr>
		</table>
			<!--/text-->		
		<!--/body content-->
		</td>
		<td width="308" style="width:0px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
	</tr>
	<!--main body-->
	<tr bgcolor="#ffffff">
		<td bgcolor="#000000" width="160" valign="top">
		<!--#include file="system/left.asp" -->
		</td>
		<!--missing 1 TD because of Rowspan-->		
		<td bgcolor="#614B00" width="308" valign="top">
			<table border="0" cellpadding="0" cellspacing="0" width="308" align="right">
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<form action="search.asp?ckid=<%=ckid%>" method="post">
				<tr bgcolor="#8D0045">
					<td width="154" valign="top" height="33" ><input type="text" name="search" value="Tìm kiếm" size="22" class="txtSearch"></td>
					<td width="154" valign="top" style="padding-top:7px;padding-left:3px;"><input type="submit" name="go" value="TÌM" class="btnGo"></td>
				</tr>
				</form>
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<!--Ads Starts-->
				<tr><td align="center" colspan="2"><img src="hinh-quang-cao/neimanmarcus350x250.jpg" alt="" width="300" height="250" border="0"></td></tr>
				<!--Ads Ends-->
			</table>
		</td>
	</tr>
	<!--/main body-->
	<!--#include file="system/bottom.asp" -->
</table>
</div>
<div id="bt2"><img src="hinh-thoi-trang/bg_bottom.gif" width="1049" height="20"></div>
</div>
</body>
</html>
